<%--/**
 * This is a fork of the UML2Java Plug-in developed by Topcased and released under
 * the Eclipse EPL License. http://www.eclipse.org/legal/epl-v10.html
 * In accordance with the license, I have forked the UML2Java plugin and have adapted
 * it to suit the needs of a UML2QoS instrumentation code generator for PHP.
 * 
 * @author Alexandru Burdusel
 */
 --%>
<%-----------------------------------Section Import---------------------------------%>
<%
metamodel http://www.eclipse.org/uml2/2.1.0/UML
import org.topcased.uml2qos.services.Uml2Services
import org.topcased.uml2qos.services.PhpServices
import org.topcased.uml2qos.services.StringServices
import org.topcased.uml2qos.services.CommentServices
import org.topcased.uml2qos.services.AttServices
import org.topcased.uml2qos.utilities.Configuration
import org.topcased.uml2qos.services.UmlQosServices

%>

<%script type="Operation" name="abstractDoc" post="indentTab()"%>
<%if (isDocNeeded()){%>
/**
 * Method for implemented abstract method : <%parent.name%>
 * @see <%parent.name%>#<%name%>
 */
<%}%>
<%script type="Operation" name="normalDoc" post="indentTab()"%>
<%if (isDocNeeded()){%>
/**
* Description for method <%name%>()
<%for (ownedParameter) {%><%if (name == "return"){%>
* @return <%for (eAnnotations.eContents.filter("EStringToStringMapEntry"))  {%><%if (key=="documentation") {%><%value%><%}%><%}%>
<%}else{%>
* @param <%name%> <%for (eAnnotations.eContents.filter("EStringToStringMapEntry"))  {%><%if (key=="documentation") {%><%value%><%}%><%}%>
<%}%><%}%>
*/
<%}%>
<%script type="Operation" name="pointcutDoc" post="indentTab()"%>
<%if (isDocNeeded()) {%>
/**
 *  Pointcut definition
 *  Will be applied to the <%name%> method in class <%parent.name%>
 */
<%}%>
<%script type="Operation" name="adviceDoc" post="indentTab()"%>
<%if (isDocNeeded()) {%>
/**
 *  Advice definition
 *  Will be applied to the before_<%name%> method in class <%parent.name%>
 */
<%}%>
<%script type="Operation" name="genOperation" post="indentTab()"%>
<%if (isAbstract) {%>abstract <%}%><%visibility%><%if (isLeaf && !isAbstract){%> final<%}%><%if (isStatic){%> static<%}%> function <%name.removePreArguments%><%genOperationParameters%><%if (isAbstract) {%>;<%}%>

<%script type="Operation" name="genOperationParameters" post="trim()"%>
(<%for (ownedParameter) {%>
<%if (name != "return") {%>$<%name%><%}%>
<%if (name !="return" && followingSibling()) {%>
<%-- Not more than a return value per function, so if we've found it and we still have other parameters, we can put a comma --%> 
<%if (followingSibling().name != "return" || followingSibling().followingSibling()){%> 
, <%}%>
<%}%><%}%>)

<%--Generate multiple return parameters as an unidimensional array--%>
<%script type="Parameter" name="genArrayParameters" post="trim()"%>
<%if (direction.equalsIgnoreCase("return").equalsIgnoreCase("true") ||
	  direction.equalsIgnoreCase("out").equalsIgnoreCase("true") ||
	  direction.equalsIgnoreCase("inout").equalsIgnoreCase("true")){%>$<%name%><%if (followingSibling()){%>, <%}%><%}%>

<%script type="Operation" name="genOperationBody" post="indentTab()"%>
<%if (!isAbstract()) {%>
{
<%addTab%>//<%startUserCode%> for <%name%>()
<%-- Return type for functions with return value --%> 
<%if ((ownedParameter.direction.filter("out").nSize()+
	  ownedParameter.direction.filter("inout").nSize()+
	  ownedParameter.direction.filter("return").nSize())/3 > 1){%>
<%addTab%>return array(<%for (ownedParameter){%><%genArrayParameters%><%}%>);
<%}else{%>
	<%for (ownedParameter){%>
		<%if (direction =="return" || direction == "out" || direction == "inout"){%>
<%addTab%>return $<%name%>; 
		<%}%>
	<%}%>
<%}%>
<%addTab%>//<%endUserCode%>
}
<%}%>
<%script type="Operation" name="genAbstractOperation" post="indentTab()"%>
<%visibility%><%if (isStatic){%> static<%}%> function <%name.removePreArguments%><%genOperationParameters%>
<%script type="Operation" name="genAbstractOperationBody" post="indentTab()"%>
{
<%addTab%>//<%startUserCode%> for <%name%>()
<%-- Return type for functions with return value --%> 
<%if ((ownedParameter.direction.filter("out").nSize()+
	  ownedParameter.direction.filter("inout").nSize()+
	  ownedParameter.direction.filter("return").nSize())/3 > 1){%>
<%addTab%>return array(<%for (ownedParameter){%><%genArrayParameters%><%}%>);
<%}else{%>
	<%for (ownedParameter){%>
		<%if (direction =="return" || direction == "out" || direction == "inout"){%>
<%addTab%>return $<%name%>; 
		<%}%>
	<%}%>
<%}%>
<%addTab%>//<%endUserCode%>
}
<%script type="Class" name="genClassProto"%>
<%if (isDocNeeded()){%>
<%generateComment%>
<%}%>
<%if (isClass){%>
<%isAbstract.stIsAbstractToString()%>class <%name%> <%if (superClass != null)
	{%>extends <%superClass.nGet(0).name%> <%}%><%if (interfaceRealization != null)
	{%> implements<%for (interfaceRealization){%> <%contract.name%><%if (followingSibling().filter("InterfaceRealization") != null){%>,<%}%><%}%><%}%>{
<%}%>
<%script type="Interface" name="genInterfaceProto"%>
<%if (isDocNeeded()){%>
<%generateComment%>
<%}%>
interface <%name%> {
<%script type="Class" name="parseEAnnotation"%>
<%for (eAnnotations){%><%addEAnnotation%><%}%>